#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>

int main(int argc, char *argv[])
{
    int pipefd[2];
    if(pipe(pipefd) == -1)
        perror("make pipe"),exit(1);

    pid_t pid;
    pid = fork();
    if(pid == -1)
        perror("make fork"),exit(1);

    if(pid == 0){
        //child
        close(pipefd[0]);
        write(pipefd[1],"hello",5);
        close(pipefd[1]);
    }

    close(pipefd[1]);
    char buf[10] = {0};
    read(pipefd[0], buf, 10);
    printf("buf=%s\n", buf);
    
    return 0;
}